package com.huawei;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * Description: HJ22 汽水瓶
 *
 * @author weiruibai.vendor
 * Date: 2022/8/18 10:43
 */
public class HJ22 {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = null;
        List<Integer> list = new ArrayList<>();
        str = br.readLine();
        while (!str.equals("0")) {
            Integer num = Integer.parseInt(str);
            list.add(num);
            str = br.readLine();
        }
        for (Integer num : list) {
            int ans = 0;
            while (num >= 3) {
                int tmp = num / 3;
                ans += num / 3;
                tmp += num % 3;
                if (tmp == 2) {
                    // 可以借1个
                    ans++;
                    break;
                }
                num = tmp;
            }
            System.out.println(ans);
        }
    }
}
